<!DOCTYPE html>
<html lang="en" class="no-js">
<head>
<meta charset="UTF-8" />
<title>开关</title>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
    $(function(){
        $.ajax({
            url : "/st",
            type:"GET",
            success : handlerState
        })
        $("#qh").click(function(){
            $.ajax({
                url : "/st",
                type:"POST",
                success : handlerState
            })
        })
        function handlerState(data){
            let state = data.state;
            let msg = state ? "开启":"关闭"
            $("#msg").text("当前已"+msg)
        }
    })
</script>
<style>
    
</style>
</head>
<body>
    <span id="msg"></span><br>
    <input type="button" value="点击开启关闭切换" id="qh">
</body>
</html>
